package com.app.ctzoverseas.page.main.home

import com.android.base_network.extend.asResponse
import com.android.basemvvm.BaseViewModel
import com.blankj.utilcode.util.LogUtils
import com.cardetective.shopcar.network.model.UserInfoModel
import com.cardetective.shopcar.utils.InjectUtil
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.catch

class MineViewModel: BaseViewModel() {

    private val accountRepo by lazy { InjectUtil.getAccountRepo() }


    private val _userInfoList = MutableSharedFlow<UserInfoModel>()
    val userInfo: SharedFlow<UserInfoModel> = _userInfoList


    fun getUserInfo() {
        launch {
            accountRepo.getUserInfo()
                .asResponse()
                .catch {throwable->
                    LogUtils.e("getBannerList is error, msg: ${throwable.message}")
                    mBVOnExceptionListener?.onListener(-1,throwable.message.toString())
                }.collect(_userInfoList)
        }
    }


}